package com.dfbz.demo01_实现TCP;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_InetAddress {
    public static void main(String[] args) throws UnknownHostException {


        InetAddress localhost = InetAddress.getByName("localhost");
        String hostName = localhost.getHostName();
        String hostAddress = localhost.getHostAddress();

        System.out.println(hostName);
        System.out.println(hostAddress);

        System.out.println("-----------");

        InetAddress baidu = InetAddress.getByName("www.baidu.com");
        System.out.println(baidu.getHostName());
        System.out.println(baidu.getHostAddress());

        System.out.println("-----------");


    }
}
